<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="目标检测——RCNN系列, J Sir">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>目标检测——RCNN系列 | J Sir</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 6.0.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">J Sir</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">J Sir</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/jy741" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/jy741" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/1.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">目标检测——RCNN系列</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">深度学习</span>
                            </a>
                        
                            <a href="/tags/%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8B/">
                                <span class="chip bg-color">目标检测</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2023-03-11
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.3k
                </div>
                

                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="奶茶鼠的想法"><a href="#奶茶鼠的想法" class="headerlink" title="奶茶鼠的想法"></a>奶茶鼠的想法</h1><p>爱很简单</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/b65e96a444662c94f82b419a13ac479868851438.jpg@1036w.webp" alt="img" style="zoom:33%;"></p>
<h1 id="R-CNN"><a href="#R-CNN" class="headerlink" title="R-CNN"></a>R-CNN</h1><p>R-CNN（Region with CNN feature）是目标检测领域的开山之作，原论文名称《Rich feature hierarchies for accurate object detection and semantic segmentation》作者是<a target="_blank" rel="noopener" href="https://www.rossgirshick.info/">Ross Girshick</a> 。</p>
<span id="more"></span>
<h2 id="算法流程"><a href="#算法流程" class="headerlink" title="算法流程"></a>算法流程</h2><p>RCNN算法流程可以分为四步：</p>
<ol>
<li>一张图像生成1K~2K个候选区域(使用Selective Search方法)</li>
<li>对每个候选区域，使用深度网络提取特征</li>
<li>特征送入每一类的SVM 分类器，判别是否属于该类</li>
<li>使用回归器精细修正候选框位置</li>
</ol>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311135655086.png" alt="image-20230311135655086"></p>
<h2 id="候选区域生成"><a href="#候选区域生成" class="headerlink" title="候选区域生成"></a>候选区域生成</h2><p> 候选区域生成在RCNN中采用的是selective search 【简称SS算法】，这个算法的原理大致是通过颜色、大小、形状等一些特征对图像进行聚类，算法的结果是在一张图片中生成一系列的候选框，RCNN中让每张图像都生成2000个候选框。这些候选框有着大量的重叠部分，因此我们后面需要将这些重叠的候选框去除，得到相对准确的候选框。下图展示了SS算法得到的大致结果，可见一个目标会有多个候选框生成。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140051997.png" alt="image-20230311140051997"></p>
<h2 id="深度网络提取特征"><a href="#深度网络提取特征" class="headerlink" title="深度网络提取特征"></a>深度网络提取特征</h2><p> 上一步我们由SS算法从一张图片中得到了2000个候选框，接下来需要对这些候选框进行特征提取，即分别将2000个候选框区域喂入ALexNet网络进行训练，提取特征。AlexNet网络结构如下所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140203357.png" alt="image-20230311140203357"></p>
<p> 需要注意的是，在RCNN中，我们不需要最后的softmax层，只需要经过最后两次全连接层，利用其提取到的特征即可。此外由于全连接层的存在，需要对输出图片的尺寸进行限制，即需要图片分辨率为227×227。论文中所采用的方法为无论候选区域的大小或纵横比如何，先将其周围扩展16个邻近像素，然后将所有像素强制缩放至227×227尺寸。【注：可见此方案会使原图像发生畸变，如人物变矮变胖等】</p>
<h2 id="SVM分类器分类"><a href="#SVM分类器分类" class="headerlink" title="SVM分类器分类"></a>SVM分类器分类</h2><p>上一步我们已经通过ALexNet网络提取到特征，每一个候选框区域都会生成4096维的特征向量，如下图所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140501622.png" alt="image-20230311140501622"></p>
<p>上图展示的是一个候选框提取到的特征，我们采用SS算法会从一幅图片中生成2000个候选框，将所有候选框输入网络，就会得到2000×4096维的特征矩阵。将2000×4096维的特征矩阵与20个SVM组成的权值矩阵4096×20相乘，会得到2000×20维的概率矩阵，其中每一行代表一个候选框属于各个目标类别的概率。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140820580.png" alt="image-20230311140820580"></p>
<p>从上图可以看出，2000<em>20维矩阵的每一列表示2000个候选框分别对某一类的预测概率，如第一列则表示2000个候选框分别对狗的预测概率。<em>*我们对每一列即每一类进行非极大值抑制（NMS）用于剔除重叠候选框，得到该列中得分最高的的建议框。</em></em>具体NMS过程如下：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140841372.png" alt="image-20230311140841372"></p>
<p>其中iou计算公式：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311140912492.png" alt="image-20230311140912492" style="zoom: 67%;"></p>
<p>可以看到这个值越大表示这两个候选框重叠的部分越多，则表示这两个候选框很可能表示的是同一个物体，那么删除得分低的候选框就很容易理解了。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141008659.png" alt="image-20230311141008659" style="zoom:80%;"></p>
<h2 id="回归器修正候选框位置"><a href="#回归器修正候选框位置" class="headerlink" title="回归器修正候选框位置"></a>回归器修正候选框位置</h2><p>上一步骤中我们剔除了许多候选框，接下来我们需要对剩余的候选框进一步筛选，即分别用20个回归器对上述20个类别中剩余的候选框进行回归操作，最终得到每个类别修正后的得分最高的bounding box。</p>
<p>如图，黄色框口P表示建议框Region Proposal，绿色窗口G表示实际框Ground Truth，红色窗口表示Region Proposal进行回归后的预测窗口，可以用最小二乘法解决的线性回归问题。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141117371.png" alt="image-20230311141117371"></p>
<p> 那么我们怎么由候选框得到最后的预测框呢？我们依旧会由ALexNet输出的特征向量来得到回归器的预测结果，其结果为$(d_x(P),d_y(P),d_w(P),d_h(P))$，其表示中心点坐标偏移及宽度和高度候选框偏移的缩放因子。其预测的结果$\hat{G_i}$的表达式如下所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141417783.png" alt="image-20230311141417783"></p>
<p>我们由上式反解 $(d_x(P),d_y(P),d_w(P),d_h(P))$的表达式，现用$(t_x,t_y,t_w,t_h)$表示，因为标注框参数和候选框参数都是给定的，因此$(t_x,t_y,t_w,t_h)$也是可直接计算得到的，为真实值。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141538302.png" alt="image-20230311141538302"></p>
<p>接下来就用$(d_x(P),d_y(P),d_w(P),d_h(P))$值去拟合$(t_x,t_y,t_w,t_h)$值，使损失函数最小，损失函数定义如下：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141649107.png" alt="image-20230311141649107"></p>
<h2 id="R-CNN存在的问题"><a href="#R-CNN存在的问题" class="headerlink" title="R-CNN存在的问题"></a>R-CNN存在的问题</h2><p>RCNN整体框架如下：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311141731037.png" alt="image-20230311141731037" style="zoom:80%;"></p>
<p>存在的问题：</p>
<ul>
<li>测试速度慢：测试一张图片约53s(CPU)。用Selective Search算法提取候选框用时约2秒，一张图像内候选框之间存在大量重叠，提取特征操作冗余。</li>
<li>训练速度慢：过程及其繁琐</li>
<li>训练所需空间大：对于SVM和bbox回归训练，需要从每个图像中的每个目标候选框提取特征，并写入磁盘。对于非常深的网络，如VGG16，从VOC07训练集上的5k图像上提取的特征需要数百GB的存储空间。</li>
</ul>
<h1 id="Fast-R-CNN"><a href="#Fast-R-CNN" class="headerlink" title="Fast R-CNN"></a>Fast R-CNN</h1><p>Fast R-CNN是作者Ross Girshick继R-CNN后的又一力作。同样使用VGG16作为网络的backbone，与R-CNN相比训练时间快9倍，测试推理时间快213倍，准确率从62%提升至66%(在Pascal VOC数据集上)。</p>
<h2 id="算法流程-1"><a href="#算法流程-1" class="headerlink" title="算法流程"></a>算法流程</h2><p>Fast R-CNN算法流程可分为3个步骤：</p>
<ol>
<li>一张图像生成1K~2K个候选区域(使用Selective Search方法)</li>
<li>将图像输入网络得到相应的特征图，将SS算法生成的候选框投影到特征图上获得相应的特征矩阵</li>
<li>将每个特征矩阵通过ROI pooling层缩放到7x7大小的特征图，接着将特征图展平通过一系列全连接层得到预测结果</li>
</ol>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311150958482.png" alt="image-20230311150958482"></p>
<h2 id="特征图-amp-特征矩阵"><a href="#特征图-amp-特征矩阵" class="headerlink" title="特征图&amp;特征矩阵"></a>特征图&amp;特征矩阵</h2><p>在R-CNN中我们输入的是经SS算法得到的2000个候选框，这显然需要巨大的计算量；而在Fast R-CNN中，我们仅需要将原始图像输入到特征提取网络中得到原始图像的特征图即可。其实这一部分是借鉴了何凯明的SPP-Net——<strong>原始图像中的某个候选框经过神经网络后会映射到所得特征图的相应位置，这个位置是可计算的。</strong></p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151146294.png" alt="image-20230311151146294"></p>
<h2 id="RoI-Pooling-Layer"><a href="#RoI-Pooling-Layer" class="headerlink" title="RoI Pooling Layer"></a>RoI Pooling Layer</h2><p>在Fast R-CNN中，我们没有像R-CNN中一样对图片进行强制缩放，而是我们在得到特征图上的映射后（也即候选框），将这些候选框进行ROI pooling操作将不同大小的候选框统一缩放至统一的大小，ROI pooling的操作如下图所示：即不论原始特征图大小如何，我们都先将特征图分成7×7=49等份，然后每一份采用最大池化或平均池化，将原特征图下采样成7×7统一大小。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151400694.png" alt="image-20230311151400694"></p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151532789.png" alt="image-20230311151532789"></p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151545581.png" alt="image-20230311151545581"></p>
<h2 id="损失函数"><a href="#损失函数" class="headerlink" title="损失函数"></a>损失函数</h2><p>损失函数共有两部分组成，一部分是分类损失，一部分是边界框回归损失。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151708637.png" alt="image-20230311151708637"></p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151725359.png" alt="image-20230311151725359"></p>
<h2 id="整体框架"><a href="#整体框架" class="headerlink" title="整体框架"></a>整体框架</h2><p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311151801720.png" alt="image-20230311151801720"></p>
<h1 id="Faster-R-CNN"><a href="#Faster-R-CNN" class="headerlink" title="Faster R-CNN"></a>Faster R-CNN</h1><p>Faster R-CNN是作者Ross Girshick继Fast R-CNN后的又一力作。同样使用VGG16作为网络的backbone，推理速度在GPU上达到5fps(包括候选区域的生成)，准确率也有进一步的提升。在2015年的ILSVRC以及COCO竞赛中获得多个项目的第一名。</p>
<p>Faster R-CNN相较于Fast R-CNN有什么要的改进呢？其实最主要的就是在Fast R-CNN中我们依旧是和R-CNN一样采用SS算法来生成候选框，而在Faster R-CNN中我们采用的是一种称为RPN（Region Proposal Network）的网络结构来生成候选框。其它部分基本和Fast R-CNN一致，所以我们可以将Faster R-CNN的网络看成两部分，一部分是RPN获取候选框网络结构，另一部分是Fast R-CNN网络结构，如下图所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230311155242010.png" alt="image-20230311155242010" style="zoom:80%;"></p>
<h2 id="整体结构"><a href="#整体结构" class="headerlink" title="整体结构"></a>整体结构</h2><ol>
<li>输入、数据预处理。首先，将尺寸大小为 M×N 的图片输入 Faster-RCNN 网络进行 resize 操作，处理图片的尺寸到 H×W，适应模型要求。</li>
<li>Conv layers——backbone提取特征。Faster-RCNN 可以采用多种的主干特征提取网络，常用的有VGG，Resnet，Xception等等。作为一种CNN网络目标检测方法，Faster RCNN使用一组基础的 conv+relu+pooling 层提取 image的feature maps ,该 feature maps 被共享用于后续 RPN 层和全连接层。也就是使用共享的卷积层为全图提取特征。</li>
<li>Region Proposal Networks。RPN网络用于生成 region proposals (目标候选区域)。将 RPN 生成的候选框投影到特征图上获得相应的特征矩阵。该层通过 softmax 判断 anchors (锚)属于前景或者背景，再利用 bounding box regression 修正 anchors 获得精确的 proposals 。</li>
<li>RoI Pooling。该层收集输入的 feature maps 和 proposals，将每个特征矩阵缩放到 7×7 大小的特征图，综合这些信息后提取 proposal 和 feature maps，送入后续全连接层判定目标类别。</li>
<li>Classifier。通过全连接层得到最后的概率，计算得到类别，同时再次 bounding box regression 获得检测框最终的精确位置。尤其注意的是，Faster R-CNN 真正实现了端到端的训练 (end-to-end training)。</li>
</ol>
<p>Faster R-CNN整体结构图如下所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/ade09f0736ef4d72b639472605528c58.jpeg" alt="Faster RCNN结构图"></p>
<h2 id="特征提取"><a href="#特征提取" class="headerlink" title="特征提取"></a>特征提取</h2><p>将VGG16作为BackBone整体网络结构如下：（这个backbone是可以根据需求更换的，像换成ResNet、MobileNet等等都是可以的。）</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/9a8511dcc265562dc4729be13f66eaca.jpeg" alt="img"></p>
<p>Conv layers部分共有 13 个 conv 层，13 个 relu 层，4 个pooling 层。</p>
<p>这里有一个非常容易被忽略但是又无比重要的信息，在 Conv layers 中：</p>
<ul>
<li>所有的conv层都是：kernel_size=3，pad=1，stride=1</li>
<li>所有的pooling层都是：kernel_size=2，pad=0，stride=2</li>
</ul>
<p>为何重要？在 Faster RCNN Conv layers 中对所有的卷积都做了扩边处理（ pad=1，即填充一圈0），导致原图变为 (M+2)x(N+2) 大小，再做 3x3 卷积后输出 MxN 。正是这种设置，导致 Conv layers 中的 conv 层不改变输入和输出矩阵大小。</p>
<p>类似的是，Conv layers 中的 pooling 层 kernel_size=2，stride=2。这样每个经过 pooling 层的 MxN 矩阵，都会变为 (M/2)x(N/2) 大小。综上所述，在整个 Conv layers 中，conv 和 relu 层不改变输入输出大小，只有 pooling 层使输出长宽都变为输入的 1/2。</p>
<p>那么，一个 MxN 大小的矩阵经过 Conv layers 固定变为 (M/16)x(N/16) ！这样 Conv layers 生成的 feature map 中都可以和原图对应起来。</p>
<h2 id="RPN网络结构"><a href="#RPN网络结构" class="headerlink" title="RPN网络结构"></a>RPN网络结构</h2><p>RPN的网络结构如下：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/fe4dee7f509c5375c81cee3b5802d2c1.png" alt="image-20220625110444667"></p>
<p>我们上一步已经得到了$\frac{M}16*\frac{N}16 $大小的特征图（Feature Map)，可以看到我们会对特征图分别进行路径①和路径②上的操作，其中路径①上的操作即为RPN网络结构。下面我们就来重点谈谈这个RPN网络结构。</p>
<p>首先我们先来明确RPN是用来干什么的？<strong>RPN就是来提取候选框的</strong></p>
<p>那么RPN到底是怎么做的呢？首先，我们会用一个3*3的滑动窗口遍历刚刚得到的特征图，之后计算出滑动窗口中心点对应原始图像上的中心点， 最后在原始图像每个中心点绘制9种anchor boxes 。【注：怎么由特征图的中心点坐标得到原图的中心点呢？——我们采用的是VGG骨干网络，原图和特征图尺寸相差16倍，因此只需要将特征图中心点坐标乘16即可；或者我们可以计算出中心点在特征图中的相对位置，进一步得到原图中心点位置】</p>
<p>我们需要在原图中绘制9中anchor，论文中给出三种尺度（128×128 、256×256 、512×512）和三种比例（1:1、1:2、2:1）一共9种anchor，说是由经验设计，其实我们在实现过程中是可以根据任务调整的，比如我们要检测的目标较小，那么就可以适当减小anchor的尺寸。特征图中心点到原图的大致映射关系图如下：</p>
<p>上文谈到使用3×3的滑动窗口遍历特征图，其实这就对应了路径①中的第一个3×3的卷积，卷积过程padding=1,stride=1。其中该卷积和原图生成anchor的对应关系如下图所示：可见经过这一步我们会在原图上生成许多许多的anchor，很明显这些anchor很多都是我们不需要的，后面就会对这些anchor进行取舍。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/eefad0920e4b37baed48132beab40193.gif" alt="pic"></p>
<p>再来对照图看看3×3的卷积后进行了什么操作？3×3卷积后由分别走路径③和路径④进行相关操作。其实路径③就是对刚刚得到的anchor进行分类（前景和背景），而路径④则是对anchor进行回归微调。</p>
<p>首先先来谈谈路径③。首先进行一个1*1的卷积，卷积核个数为18。如下图所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/efce838aaf0248f524f51cd41cc8eab0.png" alt="image-20220625151255098" style="zoom: 67%;"></p>
<p>其实上图采用18个卷积核是很有讲究的。首先我们要知道的是路径③我们要做的是区分每个anchor是前景还是背景，即分成两个类别，而对于每个小方格都会在原图上生成9个anchor。这样2*9=18，得到的结果中每个小方块就代表原始图像中某个位置每个anchor是否为前景或背景的概率。为方便大家理解，抠出某个方格对18通道的数据进行解释，如下图所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/83378d72263b012f5448c6cded09a45c.png" alt="img"></p>
<p>1*1的卷积后，就进行了softmax层进行分类。softmax层分类后我们会得到所有的正类的anchor（positive anchors）和负类的anchor（negative anchors）。</p>
<p>补充一下正负样本的选取规则：正样本有两个条件，第一：选取与真实框IOU最大的anchor；第二：选取与真实框IOU大于0.7的anchor。【注：其实大部分情况第二个条件都可以满足，但是防止存在一些极端情况设置了条件一】负样本的选取条件为与所有真实框IOU都小于0.3的anchor。</p>
<p>接着就来谈谈路径④，同样的，先是一个1*1的卷积，卷积核个数为36。如下图所示：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/47699aa320beba6a1d1b8c446256d955.png" alt="image-20220625154852032" style="zoom:67%;"></p>
<p>这里的36同样是有讲究的呀，因为在进行回归微调anchor的时候每个anchor需要四个参数，4*9=36，得到的结果中每个小方块就代表原始图像中某个位置每个anchor四个需要调整的参数。同样也画个图片帮助大家理解，如下：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/e888c7367aa4b9c43ffec707576b2597.png" alt="image-20220625155415966"></p>
<p>接下来路径③和路径④在Proposal这步结合，这步是干什么的呢？其实呀，这一步就是综合了路径③和路径④中的信息，即分类结果和anchor框的回归参数，目的是得到更加精确的候选框（Region Proposal）。细心的同学可能还发现了proposal这步还有一个输入，即im_info，这个参数保存了一些图片尺寸变换的信息，像开始的resize，后面的池化等等。</p>
<h2 id="损失函数-1"><a href="#损失函数-1" class="headerlink" title="损失函数"></a>损失函数</h2><p>RPN层的损失函数如下：RPN层的分类损失和fast R-CNN类似，也是由两部分组成，即分类损失和边界框回归损失。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/b9eb7634f641e5851e0bc9c5bb61118f.png" alt="image-20220625163317420"></p>
<p>下面来具体看看①和②部分：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/2fbe00ebb25e8d44c5a967d2d037e823.png" alt="image-20220625163554470"></p>
<h2 id="ROLPooling"><a href="#ROLPooling" class="headerlink" title="ROLPooling"></a>ROLPooling</h2><p>上文已经较为详细的讲述了RPN层，即我们图中的①路径，接下来我们继续来讲路径②【路径②为ROI Pooling层】。我们传入ROI Pooling层的输入为原始特征图和RPN输出的候选框，我们相当于是把每个候选框对应到原始特征图的不同部分，然后把这些部分剪裁下来分别传入ROI Poolinng层。可以看到ROI Pooling层的输入有两个：分别为</p>
<ul>
<li>原始的feature maps</li>
<li>RPN输出的proposal</li>
</ul>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/30e99ef955ef4e3c897117e05572d18d.png" alt="img"></p>
<h2 id="Faster-R-CNN训练"><a href="#Faster-R-CNN训练" class="headerlink" title="Faster R-CNN训练"></a>Faster R-CNN训练</h2><p>采用RPN Loss+ Fast R-CNN Loss的联合训练方法：</p>
<ol>
<li>利用ImageNet预训练分类模型初始化前置卷积网络层参数，并开始单独训练RPN网络参数；</li>
<li>固定RPN网络独有的卷积层以及全连接层参数，再利用ImageNet预训练分类模型初始化前置卷积网络参数，并利用RPN网络生成的目标建议框去训练Fast RCNN网络参数。</li>
<li>固定利用Fast RCNN训练好的前置卷积网络层参数，去微调RPN网络独有的卷积层以及全连接层参数。</li>
<li>同样保持固定前置卷积网络层参数，去微调Fast RCNN网络的全连接层参数。最后RPN网络与Fast RCNN网络共享前置卷积网络层参数，构成一个统一网络。</li>
</ol>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">J Sir</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://jy741.gitee.io/2023/03/11/mu-biao-jian-ce-rcnn-xi-lie/">https://jy741.gitee.io/2023/03/11/mu-biao-jian-ce-rcnn-xi-lie/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">J Sir</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">深度学习</span>
                                </a>
                            
                                <a href="/tags/%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8B/">
                                    <span class="chip bg-color">目标检测</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2023/03/14/shen-jing-wang-luo-ya-suo-network-compression/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/18.jpg" class="responsive-img" alt="神经网络压缩 Network Compression">
                        
                        <span class="card-title">神经网络压缩 Network Compression</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            奶茶鼠的想法Melody~脑海中的旋律转个不停

                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2023-03-14
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            J Sir
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">深度学习</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2023/03/07/qiang-hua-xue-xi-reinforcement-learning/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/19.jpg" class="responsive-img" alt="强化学习Reinforcement Learning">
                        
                        <span class="card-title">强化学习Reinforcement Learning</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            奶茶鼠的想法三月🥰

                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2023-03-07
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            J Sir
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">机器学习</span>
                    </a>
                    
                    <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">深度学习</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h1, h2, h3, h4, h5'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h1, h2, h3, h4, h5').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>


<script src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
    MathJax.Hub.Config({
        tex2jax: {inlineMath: [['$', '$'], ['\(', '\)']]}
    });
</script>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2020-2023</span>
            
            <span id="year">2020</span>
            <a href="/about" target="_blank">J Sir</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">300.9k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="mailto:2065373132@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2065373132" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2065373132" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

	
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"live2d-widget-model-hibiki"},"display":{"position":"right","width":145,"height":315},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>

</html>
